//
//  AIFGetCouponManager.m
//  PywSdk
//
//  Created by apple on 16/1/27.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFGetCouponManager.h"

@implementation AIFGetCouponManager

NSString *const GetCoupon_Account = @"account";
NSString *const GetCoupon_Token = @"token";
NSString *const GetCoupon_Passport = @"passport";
NSString *const GetCoupon_Passport_Token = @"passport_token";
NSString *const GetCoupon_Status = @"status";
NSString *const GetCoupon_AccountType = @"account_type";
NSString *const GetCoupon_GameId = @"gameid";
NSString *const GetCoupon_Tid = @"tid";
NSString *const GetCoupon_Sign = @"sign";
NSString *const GetCoupon_Page = @"page";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
        
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_GETCOUPONS;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}


#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    
    NSString * tid = [PywAppInfo sharedAppInfo].tid;
    NSString * account = [PywPlatformMain sharedPlatformMain].account;
    NSString *passport = [PywPlatformMain sharedPlatformMain].passport;
    NSString * gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString * token = [PywPlatformMain sharedPlatformMain].token;
    
    NSString * apiSeret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    
    NSString * sign = [PywCipherUtils md5:[NSString stringWithFormat:@"%@%@%@",@(_status), account,apiSeret2]];
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    
    [param setObject:account forKey:GetCoupon_Account];
    [param setObject:passport forKey:GetCoupon_Passport];
    [param setObject:@(_status) forKey:GetCoupon_Status];
    [param setObject:@([PywPlatformMain sharedPlatformMain].accountType) forKey:GetCoupon_AccountType];
    [param setObject:gameid forKey:GetCoupon_GameId];
    [param setObject:tid forKey:GetCoupon_Tid];
    [param setObject:sign forKey:GetCoupon_Sign];
    [param setObject:@(self.page) forKey:GetCoupon_Page];
    if ([PywPlatformMain sharedPlatformMain].accountType == UserType_Passport) {
        [param setObject:[PywPlatformMain sharedPlatformMain].passport_Token forKey:GetCoupon_Passport_Token];
    }else{
        [param setObject:token forKey:GetCoupon_Token];
        [param setObject:@"" forKey:GetCoupon_Passport];
    }
    return param;
}



#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}


@end
